package com.iversonx.responsibility_chain.example_1.v2;

import com.iversonx.responsibility_chain.example_1.v1.FeeRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 *
 **/
@Component
public class HandlerChain {
    @Autowired
    private List<AbstractFeeRequestHandler> handlers;
    
    public String handle(FeeRequest parameter) {
        String result = null;
        for(AbstractFeeRequestHandler handler : handlers) {
            result = handler.handle(parameter);
            if(result != null) {
                break;
            }
        }
        return result;
    }
}
